<template>
	<view style="height: 100%;width: 100%;">
		<view v-if="panduan == 7" style="position: fixed;width: 310.5rpx;top: 530rpx;left: 220rpx;display: flex;flex-direction: column;align-items: center;">
			<view>
				<image :src="kong" style="width: 310.5rpx;height: 255rpx;vertical-align: middle;"></image>
			</view>
			<view style="font-size: 30rpx;color: #585858;margin: 60rpx 0 30rpx 0;">登录查看详情</view>
			<view style="width: 272rpx;height: 76.6rpx;background: #FF7300;color: #FFFFFF;font-size: 30rpx;font-weight: bold;border-radius: 38.36rpx;line-height: 76.6rpx;text-align: center;" @tap.stop="godenglu">登录</view>
		</view>
		<view style="margin-left: 25.77rpx;margin-bottom: 150rpx;">
			<view v-for="(itme,index) in shuju" :key="index" style="width: 700.64rpx;background: #FFFFFF;border-radius: 18.1rpx;margin-bottom: 20.684rpx;box-sizing: border-box;padding: 16rpx 30.2rpx 30.2rpx 30.2rpx;letter-spacing: 2rpx;border: 0.05rpx solid #BEBEBE;position: relative;"  @tap="yueke(itme)">
				<view  class="suofang">预约</view>
				<view style="display: flex;justify-content: space-between;">
					<view style="display: flex;align-items: center;">
						<image :src="itme.map.mechanismEntity.mechanism_logo" style="width: 50rpx;height: 50rpx;border-radius: 50%;margin-right: 16rpx;vertical-align:top;border: #D6D6D6 0.09rpx solid;" ></image>
						<text style="font-size: 28.744rpx;color: #414141;">{{itme.map.mechanismEntity.mechanism_name}}</text>
					</view>
					<view style="font-size: 25rpx;">
						<image :src="zhijian" style="width: 16.3rpx;height: 24.15rpx;margin-left: 12rpx;vertical-align: middle;"></image>
					</view>
				</view>
				<view style="display: flex;justify-content: space-between;align-items: center;">
					<view style="font-size: 35rpx;font-weight: bold;color: #414141;margin: 20rpx 0 20rpx 0;">{{itme.map.masterSetPriceEntity.title}}</view>
				</view>
				<view style="color: #BEBEBE;font-size: 26.15rpx;">
					<text v-if="itme.time != ''">最近上课预约</text>
					<text v-if="itme.time == ''">暂未预约课程</text>
					<text style="margin-left: 10rpx;color: #EE7B30;">{{itme.time}}</text>
				</view>
			</view>
		</view>
	</view>
</template>
<script>
	export default {
		data(){
			return {
				user_id: "",
				num: 1,
				shuju: [],
				list: 0,
				panduan: 6,
				active: 1,
				content: "",
				kong: "http://img.curiousmore.com/968125",
				zhijian: "http://img.curiousmore.com/578648"
			}
		},
		methods:{
			go_pintuan(itme){
				let me = this
				if(itme.user_group_id == ""){
					uni.showModal({
					    title: '发起拼团',
					    content: '请重新确认',
					    success: function (res) {
					        if (res.confirm) {
								me.pintuan(itme)
					        } else if (res.cancel) {
					           
					        }
					    }
					})
				}else{
					uni.navigateTo({
					   	url: "/pages/Friend/creatGroup/creatGroup?num=" + itme.user_group_id 
					})
				}
			},
			async	pintuan(itme){
					const res = await this.$myRequest({
						url: "/userGrouping/insertUserGrouping",
						methed: "post",
						data: {
							user_id: itme.user_id,
							master_set_price_id: itme.studycard_id,
							study_card_id: itme.id
						},
						header: {
							'content-type': 'application/json'
						}
					})
					if(res.code == 0){
						let data = {
							group_id: res.data
						}
						uni.navigateTo({
						   	url: "/pages/Friend/creatGroup/creatGroup?num=" + res.data 
						})
					}else{
						uni.showToast({
							title: res.message
						})
					}
				},
			godenglu(){
				uni.navigateTo({
					url:"/pages/tabBer/login/logins"
				})
			},
			yueke(itme){
				uni.navigateTo({
					url:'/pages/World/Createstudio/Createstudio?num=' + encodeURIComponent(JSON.stringify(itme))
				})
			},
		async	qingqiu(){
				// uni.showLoading({
				//     title: '加载中'
				// });
				if(this.user_id != ""){
					const res = await this.$myRequest({
						url:"/userStudyCard/queryExclusiveCoursesList",
						method:"get",
						data:{
							currentPage:this.num,
							pageSize:10,
							platform:"ios",
							type:"mechanism_offline",
							user_id:this.user_id
						}
					})
					if(res.code == 0){
						if(res.data.length < 10){
							this.list = 1
						}
						if(this.shuju.length == 0 && res.data.length != 0){
							this.shuju = res.data
						}else if(res.data.length != 0){
							this.shuju =  this.shuju.concat(res.data)
						}
						this.shuju.forEach((itme) => {
							if(itme.map.userAppointmentEntity.hasOwnProperty("start_time")){
								itme.time = itme.map.userAppointmentEntity.start_time
							}else{
								itme.time = ""
							}
							if(itme.user_group_id == ""){
								itme.content = "发起拼团"
								itme.back = "#FF7300"
							}else{
								itme.content = "进入拼团"
								itme.back = "#2B9939"
							}
						})
						if(this.shuju.length == 0){
							uni.showModal({
							    title: '购买课程',
							    content: '前往购买课程',
							    success: function (res) {
							        if (res.confirm) {
							           uni.navigateTo({
											url:"/pages/Friend/videoChat/videoChat"
							           })
							        } else if (res.cancel) {
							            uni.showToast({
							            	title: "取消成功"
							            })
							        }
							    }
							});
						}
					}
					// uni.hideLoading()
				}
			}
		},
		onLoad() {
			try{
				if(uni.getStorageSync('userif_list').user_id){
					this.user_id = uni.getStorageSync('userif_list').user_id
				}else{
					this.panduan = 7
				}
			}catch(e){}
			this.qingqiu()
		},
		onShow() {
			
		},
		onReachBottom() {
			if(this.list == 0){
				this.num++
				this.qingqiu()
			}
		}
	}
</script>
<style lang="scss" scoped>
	.suofang{
		animation:mymove  1s linear infinite;
		-webkit-animation:mymove 0.2s ease 1 infinite; /*Safari and Chrome*/
		background: #FF7300;
		color: #FFFFFF;
		min-width: 100rpx;
		height: 40rpx;
		padding: 5rpx 10rpx;
		text-align: center;
		line-height: 30rpx;
		border-radius: 22rpx;
		font-size: 20rpx;
		top: 15rpx;
		left: 500rpx;
		box-sizing: border-box;
		position: absolute;
		z-index: 121212;
	}
	@keyframes mymove{
		0%{
		transform: scale(1);  /*开始为原始大小*/
		}
		50%{
			transform: scale(1.1);
		}
		100%{
			transform: scale(1);
		}
	}
</style>
